home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / watcom / w_512400 / 512.asm < prev    next >
Encoding:
Assembly Source File  |  1995-01-08  |  6.1 KB  |  226 lines

  1.          .386p
  2. DGROUP   GROUP _TEXT
  3.  
  4. _TEXT    SEGMENT BYTE PUBLIC 'CODE'
  5.          ASSUME CS:_TEXT ,DS:DGROUP,SS:DGROUP
  6.  
  7. _aci     equ 3c0h
  8. _mo      equ 3c2h
  9. _sci     equ 3c4h
  10. _gfxi    equ 3ceh
  11. _crtci   equ 3d4h
  12.  
  13.          public set_512x400_
  14.          public set_plane_
  15.          public pixel_plot_
  16.  
  17. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  18. ; Plot pixel in 512x400 video mode (slow, testing purposes only)
  19. ; In:
  20. ;  ECX = x
  21. ;  EAX = y
  22. ;   BL = colour to plot
  23. ;
  24. ; Notes:
  25. ;  This routine could sometimes be inacurate if you change the plane yourself
  26. ;  because it checks for the last plane selected and skips the expensive OUT
  27. ;  DX,AL if it will write to the same plane anyway.
  28. ;
  29. ;  Like I said, It's just for testing purposes.
  30. ;
  31. ; Modifies ESI EDX EAX
  32. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  33.  
  34. _lastplane db -1
  35.  
  36. pixel_plot_:
  37.          mov esi,eax
  38.          shl eax,5                     ; * 32
  39.          and ah,0f0h
  40.  
  41.          cmp ah,_lastplane
  42.          je short pp_skipout
  43.          mov _lastplane,ah
  44.  
  45.          mov dx,_gfxi
  46.          mov al,09h
  47.          out dx,ax
  48. pp_skipout:
  49.          and esi,07fh
  50.          shl esi,9                     ; * 512
  51.          mov [0a0000h+esi+ecx],bl
  52.          ret
  53.  
  54. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  55. ; Set flat video mode 512x400 for Cirrus Logic 54xx series SVGA cards
  56. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  57.  
  58. set_512x400_:
  59.          mov dx,3dah                   ; disable video output
  60.          in al,dx
  61.          call sm_acwait
  62.          mov dx,_aci
  63.          xor ax,ax
  64.          out dx,al
  65.  
  66.          mov dx,_sci                   ; set syncronous reset
  67.          mov ax,100h
  68.          out dx,ax
  69.  
  70.          mov esi,offset _modat         ; set dot clock (25mhz)
  71.          mov dx,_mo
  72.          lodsb
  73.          out dx,al
  74.  
  75.          mov esi,offset _scdat         ; load sequencer regs (and disable video)
  76.          mov ecx,_sclen
  77.          mov dx,_sci
  78.          rep outsw
  79.  
  80.          mov esi,offset _acdat         ; load attribute regs
  81.          mov ecx,_aclen
  82. sm_acinit:
  83.          mov dx,3dah
  84.          in al,dx
  85.          call sm_acwait
  86.          mov dx,_aci
  87.          lodsb
  88.          out dx,al
  89.          call sm_acwait
  90.          lodsb
  91.          out dx,al
  92.          call sm_acwait
  93.          dec cl
  94.          jnz short sm_acinit
  95.  
  96.          mov dx,_crtci                 ; unprotect crt 0-7 and cirrus extensions
  97.          mov al,11h
  98.          out dx,al
  99.          inc dx
  100.          in al,dx
  101.          and al,7fh
  102.          out dx,al
  103.          mov dx,_sci
  104.          mov ax,1206h
  105.          out dx,ax
  106.  
  107.          mov esi,offset _crtcdat       ; load crtc and gfx regs
  108.          mov ecx,_crtclen
  109.          mov dx,_crtci
  110.          rep outsw
  111.          mov esi,offset _gfxdat
  112.          mov ecx,_gfxlen
  113.          mov dx,_gfxi
  114.          rep outsw
  115.  
  116.          mov ecx,0cffffh               ; wait for video stability
  117. sm_mc1del:
  118.          loop sm_mc1del
  119.  
  120.          mov dx,3ceh                   ; clear video
  121.          mov al,09h
  122.          out dx,al
  123.          inc dx
  124.  
  125. sm_mc1l1:
  126.          out dx,al
  127.  
  128.          xor eax,eax
  129.          mov eax,0f0f0f0fh
  130.          mov edi,0a0000h
  131.          mov ecx,4000h
  132.          rep stosd
  133.  
  134.          in al,dx
  135.          add al,10h
  136.          jnc sm_mc1l1
  137.  
  138.          xor al,al
  139.          out dx,al
  140.  
  141.          mov dx,3dah                   ; enable video
  142.          in al,dx
  143.          call sm_acwait
  144.          mov dx,_aci
  145.          mov ax,20h
  146.          out dx,al
  147.          mov edx,_sci
  148.          mov ax,0101h
  149.          out dx,ax
  150.          ret
  151.  
  152. sm_acwait:
  153.          nop
  154.          nop
  155.          nop
  156.          nop
  157.          nop
  158.          nop
  159.          nop
  160.          nop
  161.          nop
  162.          ret
  163.  
  164. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  165. ; Select video plane
  166. ; In:
  167. ;  AL = video plane to switch to
  168. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  169.  
  170. set_plane_:
  171.          mov dx,_gfxi
  172.          mov ah,al
  173.          mov al,09h
  174.          out dx,ax
  175.          ret
  176.  
  177. _modat   db 0e3h
  178. _acdat   db 000h,000h,001h,001h,002h,002h,003h,003h,004h,004h,005h,005h
  179.          db 006h,006h,007h,007h,008h,008h,009h,009h,00ah,00ah,00bh,00bh
  180.          db 00ch,00ch,00dh,00dh,00eh,00eh,00fh,00fh,010h,001h,011h,000h
  181.          db 012h,00fh,013h,000h,014h,000h
  182. _aclen   equ ($-_acdat)/2
  183.  
  184. _crtcdat dw 04d00h                     ;horizontal total
  185.          dw 03f01h                     ;horizontal display end
  186.          dw 04002h                     ;start horizontal blanking
  187.          dw 08d03h                     ;end horizontal blanking
  188.          dw 04104h                     ;start horizontal retrace
  189.          dw 00d05h                     ;end horizontal retrace
  190.          dw 0a206h                     ;vertical total
  191.          dw 01f07h                     ;overflow: lots'a higher bits for these registers
  192.          dw 00008h
  193.          dw 04009h                     ;some more overflow
  194.          dw 0000ah
  195.          dw 0000bh
  196.          dw 0000ch
  197.          dw 0000dh
  198.          dw 0000eh
  199.          dw 0000fh
  200.          dw 09010h                     ;start vertical retrace
  201.          dw 0a611h                     ;end vertical retrace
  202.          dw 08f12h                     ;vertical display end
  203.          dw 04013h                     ;offset: bytes-per-scanline/8
  204.          dw 00014h
  205.          dw 09015h                     ;start vertical blank
  206.          dw 09116h                     ;end vertical blank
  207.          dw 0c317h
  208.          dw 0ff18h                     ;line compare: no split screen
  209.          dw 00019h
  210.          dw 0001ah
  211.          dw 0221bh
  212. _crtclen equ ($-_crtcdat)/2
  213.  
  214. _gfxdat  dw 00000h,00001h,00002h,00003h,00004h,04005h
  215.          dw 00506h,00f07h,0ff08h,00009h,0000ah,0000bh
  216. _gfxlen  equ ($-_gfxdat)/2
  217.  
  218. _scdat   dw 00300h,02101h,00f02h,00003h,00e04h,00f05h,01206h,00107h
  219.          dw 08008h,00109h,0190ah,04a0bh,05b0ch,0450dh,04a0eh,0300fh
  220.          dw 00010h,00011h,00012h,00013h,00014h,00015h,0d816h,00017h
  221.          dw 00018h,00119h,0001ah,02b1bh,02f1ch,0301dh,02b1eh,01c1fh
  222. _sclen   equ ($-_scdat)/2
  223.  
  224. _TEXT    ends
  225.          end
  226.